package com.ihome.android.market2.adapter;

import java.util.List;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.ihome.android.market2.view.LoopViewPager;

/**
 * FragmentPager Adapter to show Fragments 
 * @author Emerson
 *
 */
public class FragmentAdapter extends FragmentPagerAdapter {

	public List<Fragment>	mListFrag;

	public FragmentAdapter(FragmentManager fm) {
		super(fm);
	}

	public FragmentAdapter(FragmentManager fm, List<Fragment> mListFrag) {
		super(fm);
		this.mListFrag = mListFrag;
	}


	@Override
	public Fragment getItem(int position) {
		
		//position = LoopViewPager.toRealPosition(position, getCount());
		return (mListFrag == null || mListFrag.size() == 0) ? null : mListFrag.get(position);
	}

	@Override
	public int getCount() {
		return mListFrag == null ? 0 : mListFrag.size();
	}
	
}
